package com.qhzz.waveviewdemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private WaveView wave;
    private TextView edit;
    private int currentVolume;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        wave = ((WaveView) findViewById(R.id.main_wave));
        edit = ((TextView) findViewById(R.id.main_edit));
        findViewById(R.id.main_plus).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (currentVolume < 30) {
                    currentVolume ++;
                }
                wave.setVolume(currentVolume);
                edit.setText("当前音量：" + currentVolume);
            }
        });
        findViewById(R.id.main_click).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                wave.startAnim();
            }
        });

        findViewById(R.id.main_subtract).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (currentVolume > 0) {
                    currentVolume --;
                }
                wave.setVolume(currentVolume);
                edit.setText("当前音量："+currentVolume);
            }
        });

    }
}
